/**
 * 
 */
package net.phoenix.repository.query.jql;

import javax.jcr.query.qom.BindVariableValue;

/**
 * @author lixf
 *
 */
public class ParameterAST extends JQLBaseAST implements BindVariableValue{

	/**
	 * 
	 */
	private static final long serialVersionUID = -4409783796264010817L;

	@Override
	public String getBindVariableName() {		
		return this.getFirstChild().getText();
	}

	@Override
	public String toJQL() {	
		return "$"+ this.getBindVariableName();
	}
	@Override
	public String toString() {	
		return "$"+ this.getBindVariableName();
	}
	/* (non-Javadoc)
	 * @see net.phoenix.repository.query.parser.JQLBaseAST#generateSQL(net.phoenix.repository.query.parser.JQLQuery)
	 */
	@Override
	public void generateSQL(JQL2SQL collector) {
		collector.addParameter(this.getBindVariableName());
		collector.push("?");
	}

}
